package com.gl.glcourses.services.impl;

import java.util.List;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.beans.factory.annotation.Autowired;

import com.gl.glcourses.repository.ICursosRepository;
import com.gl.glcourses.repository.ITipoRecursoRepository;
import com.gl.glcourses.services.IAdjuntoServices;
import com.gl.glcourses.services.ITipoRecursoServices;
import com.gl.glcourses.vos.*;


public class TipoRecursoServices implements ITipoRecursoServices {
	@Autowired
	ITipoRecursoRepository repotporec;
	 
	@Autowired
	ICursosRepository repocurso;
	
	protected final Log logger = LogFactory.getLog(getClass());
	


public Confirmacion agregarTpoRec(TipoRecurso tipo) throws Exception {
	Confirmacion confirmacion = new Confirmacion();

	if (repotporec.findTipoRecurso(tipo.getNombre())==null){
		repocurso.save(tipo);
	}
	return confirmacion;
}

/* Traemos el listado Tipos de Recurso */
//@Cachea(cacheKey="categorias", expireTime=0)
public List<TipoRecurso> listarTpoRec() {
	logger.info("getTipoRecList");
	try {
		return repotporec.getListEntity(TipoRecurso.class);
	} catch (Exception e) {
		// TODO Auto-generated catch block
		e.printStackTrace();
	}
	return null;
}
}
